<?php
/**
 * @package    indie-bookstore
 * @subpackage bookstore
 * @author David Neimeyer davidneimeyer@gmail.com
 * administrator/components/com_bookstore/admin.bookstore.php
 * @link http://indie-bookstore.googlecode.com/
 * @license    GNU/GPL
 * 
 * @review verify joomla docs/forums for approved method of acl;
 *  consider utilizing acl in all backend for granular control
 */


// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
* define acl as suggested at jforum (http://forum.joomla.org/index.php/topic,152129.0.html)
*/
$acl =& JFactory::getACL();
$acl->addacl('com_bookstore', 'manage', 'users', 'super administrator');
$acl->addacl('com_bookstore', 'manage', 'users', 'Manager');
//$acl->addacl('com_bookstore', 'manage', 'users', 'manager');
//$acl->_mos_add_acl('com_bookstore', 'manage', 'users', 'Super Administrator');
//$controller = new myExtensionController();
//$controller->setAccessControl('com_myExtension');
/*
 * Make sure the user is authorized to view this page
 */
//$user = & JFactory::getUser();
//if (!$user->authorize( 'com_bookstore', 'manage' )) {
	//$mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
//}

// Require the base controller
require_once (JPATH_COMPONENT.DS.'controller.php');

// Require specific controller if requested
if($controller = JRequest::getWord('controller', 'application')) {
	$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
	if (file_exists($path)) {
		require_once ($path);
	} else {
		$controller = '';
	}
}

// Create the controller
$classname	= 'BookstoreController'.ucfirst($controller);
$controller	= new $classname( );
//$controller->setAccessControl('com_bookstore');

/*
 * Make sure the user is authorized to view this page
 */
$user = & JFactory::getUser();
if (!$user->authorize( 'com_bookstore', 'manage' )) {
	$mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
}


// Perform the Request task
$controller->execute( JRequest::getCmd('task'));
$controller->redirect();

?>